package com.zhss.eshop.schedule.mapper;

import com.zhss.eshop.schedule.domain.model.ScheduleOrderSendOutDetail;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ScheduleOrderSendOutDetailMapper {
    int deleteByPrimaryKey(Long id);

    int insertSelective(ScheduleOrderSendOutDetail record);

    ScheduleOrderSendOutDetail selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(ScheduleOrderSendOutDetail record);

    /**
     * 根据订单id和订单条目id查询发货明细
     * @param orderInfoId 订单id
     * @param orderItemId 订单条目id
     * @return
     */
    @Select("SELECT "
            + "id,"
            + "order_info_id,"
            + "order_item_id,"
            + "goods_allocation_stock_detail_id,"
            + "send_out_count,"
            + "gmt_create,"
            + "gmt_modified "
            + "FROM schedule_order_send_out_detail "
            + "WHERE order_info_id=#{orderInfoId} "
            + "AND order_item_id=#{orderItemId}")
    @Results({
            @Result(column = "id", property = "id", id = true),
            @Result(column = "order_info_id", property = "orderInfoId"),
            @Result(column = "order_item_id", property = "orderItemId"),
            @Result(column = "goods_allocation_stock_detail_id", property = "goodsAllocationStockDetailId"),
            @Result(column = "send_out_count", property = "sendOutCount"),
            @Result(column = "gmt_create", property = "gmtCreate"),
            @Result(column = "gmt_modified", property = "gmtModified")
    })
    List<ScheduleOrderSendOutDetail> listByOrderItemId(
            @Param("orderInfoId") Long orderInfoId,
            @Param("orderItemId") Long orderItemId);
}
